package com.yupi.yupicturebackend.api.imagesearch.baidu;

import com.yupi.yupicturebackend.api.imagesearch.baidu.model.ImageSearchResult;
import com.yupi.yupicturebackend.api.imagesearch.baidu.sub.GetImageFirstUrlApi;
import com.yupi.yupicturebackend.api.imagesearch.baidu.sub.GetImageListApi;
import com.yupi.yupicturebackend.api.imagesearch.baidu.sub.GetImagePageUrlApi;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Deprecated
@Slf4j
public class ImageSearchApiFacade {

    /**
     * 业务：搜索图片
     * 【门面模式】 通过提供一个统一的接口来简化多个接口的调用，使得客户端不需要关注内部的具体实现。
     */
    public static List<ImageSearchResult> searchImage(String imageUrl) {
        String imagePageUrl = GetImagePageUrlApi.getImagePageUrl(imageUrl);
        String imageFirstUrl = GetImageFirstUrlApi.getImageFirstUrl(imagePageUrl);
        List<ImageSearchResult> imageList = GetImageListApi.getImageList(imageFirstUrl);
        return imageList;
    }

//    public static void main(String[] args) {
//        // 测试以图搜图功能
//        String imageUrl = "https://www.codefather.cn/logo.png";
//        List<ImageSearchResult> resultList = searchImage(imageUrl);
//        System.out.println("结果列表" + resultList);
//    }
}
